/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd.            */
/*                                                                 */
/*  NAME      = activeMQ_boolean_stream_parse1.c                      */
/*  NOTE      =                                                    */
/*  DATE      = 2015/05/21 by geyh                                 */
/*******************************************************************/


#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>

#include "frmem.h"
#include "frcomm.h"
#include "frbyte_buffer.h"
#include "../../src/module/activemq/activemq_common.h"
#include "../../src/module/activemq/activemq_base_type.h"
#include "../../src/module/activemq/activemq_core.h"
#include "apmtest_cunit.h"
#include "../../../src/module/activemq/config.h"

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

int activeMQ_boolean_stream_parse1(ACTIVEMQ_boolean *p_st_boolean);


static void __case1(void)
{
    ACTIVEMQ_boolean *p_st_boolean = NULL;
    int i_ret = 0;

    i_ret = activeMQ_boolean_stream_parse1(p_st_boolean);

    CU_ASSERT_EQUAL(i_ret,-1);

    return;

}

static void __case2(void)
{
    ACTIVEMQ_boolean *p_st_boolean = NULL;
    int i_ret = 0;

    p_st_boolean = (ACTIVEMQ_boolean *)frmalloc(sizeof(ACTIVEMQ_boolean));
    memset(p_st_boolean, 0x00, sizeof(ACTIVEMQ_boolean));

    p_st_boolean->p_boolean_data = (char *)frmemdup((char *)"\x01",1);
    p_st_boolean->us_arraylimit = 1;
    p_st_boolean->us_arraypos = 0;
    p_st_boolean->us_bytepos = 0;

    i_ret = activeMQ_boolean_stream_parse1(p_st_boolean);

    CU_ASSERT_EQUAL(i_ret,1);
    frfree(p_st_boolean->p_boolean_data);
    frfree(p_st_boolean);

    return;

}

static void __case3(void)
{
    ACTIVEMQ_boolean *p_st_boolean = NULL;
    int i_ret = 0;

    p_st_boolean = (ACTIVEMQ_boolean *)frmalloc(sizeof(ACTIVEMQ_boolean));
    memset(p_st_boolean, 0x00, sizeof(ACTIVEMQ_boolean));

    p_st_boolean->p_boolean_data = (char *)frmemdup((char *)"\x00",1);
    p_st_boolean->us_arraylimit = 1;
    p_st_boolean->us_arraypos = 0;
    p_st_boolean->us_bytepos = 5;

    i_ret = activeMQ_boolean_stream_parse1(p_st_boolean);

    CU_ASSERT_EQUAL(i_ret,0);
    frfree(p_st_boolean->p_boolean_data);
    frfree(p_st_boolean);

    return;

}

static void __case4(void)
{
    ACTIVEMQ_boolean *p_st_boolean = NULL;
    int i_ret = 0;

    p_st_boolean = (ACTIVEMQ_boolean *)frmalloc(sizeof(ACTIVEMQ_boolean));
    memset(p_st_boolean, 0x00, sizeof(ACTIVEMQ_boolean));

    p_st_boolean->p_boolean_data = (char *)frmemdup((char *)"\x00",1);
    p_st_boolean->us_arraylimit = 1;
    p_st_boolean->us_arraypos = 0;
    p_st_boolean->us_bytepos = 8;

    i_ret = activeMQ_boolean_stream_parse1(p_st_boolean);

    CU_ASSERT_EQUAL(i_ret,-1);
    frfree(p_st_boolean->p_boolean_data);
    frfree(p_st_boolean);

    return;

}

int add_suite_activeMQ_boolean_stream_parse1(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" activeMQ_boolean_stream_parse1()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", __case1) == NULL ||
        CU_add_test(pSuite, "case2", __case2) == NULL ||
        CU_add_test(pSuite, "case3", __case3) == NULL ||
        CU_add_test(pSuite, "case4", __case4) == NULL)
        return FR_FAIL;

    return FR_SUCC;

}

